<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const weather = new Promise((resolve, rejiect) => {
            setTimeout(() => {
                resolve({ trmp: 29, conditions: 'Sunny with Clouds' })
            }, 5000)
        });
        const tweets = new Promise((resolve, rejiect) => {
            setTimeout(() => {
                resolve(['I like beer', 'BBQ is good too!'])
            }, 3000)
        })
        // weather
        //     .then((data) => {// data拿到的是resolve传的值或者运行结果
        //         // 拿到了天气
        //         console.log(data)
        //         // 又返回来一个Promise实例
        //         return tweets
        //     })
        //     .then((data) => {
        //         // tweets
        //         console.log(data)
        //     })
        Promise
            .all([weather, tweets]) // all是Promise类的静态方法 ，作用：所有都执行完了
            .then(response => {
                // console.log(response)
                const [weatherInfo, tweetsInfo] = response;
                console.log([weatherInfo, tweetsInfo])
            })
    </script>
</body>

</html>